#include <bits/stdc++.h>
using namespace std;

#define N 100000

struct Tree
{
    int value;
    char r = '*', l = '*';
}tree[N];

void preorder(Tree a[N], char begin)
{
    printf("%c", begin);
    if(a[int(begin)].l != '*')preorder(a, a[int(begin)].l);
    if(a[int(begin)].r != '*')preorder(a, a[int(begin)].r);
}

int main()
{
    int n;
    cin >> n;
    char begin ;
    for(int i = 0; i<n; i++)
    {
        char a, b, c;
        cin>> a>> b>> c;
        if(i == 0)begin = a;
        tree[int(a)].l = b;
        tree[int(a)].r = c;
    }
    preorder(tree, begin);
}